home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Pascal / Code Resources / Ingis WDEF 1.3 / IngisWDEF.p < prev    next >
Text File  |  1997-05-09  |  19KB  |  550 lines

  1. { *** Main unit for the "IngisWDEF" WDEF building package *** }
  2.  
  3. {© 1994-1997 by Ingemar Ragnemalm}
  4. {You may use it freely as long as credits are given in the final program.}
  5.  
  6.  
  7. {***  IngisWDEF  ***}
  8. {}
  9. {Version 1.3}
  10. {}
  11. {This WDEF is written in order to be as easily customized as possible, in order to produce new}
  12. {interesting WDEFs. The code consists of two parts, IngisWDEF.p and CustomStubs.p. The idea is}
  13. {to separate code that must be changed from code that can remain the same.}
  14. {}
  15. {The code in IngisWDEF will seldom have to be modified when making a new WDEF.}
  16. {}
  17. {CustomStub (which comes in several versions, one for each demo and one with empty stubs)}
  18. {is where your code goes. You create a grow region, a close box, draw the drag bar and create the}
  19. {contents and drag regions.}
  20. {}
  21. {An important point with IngisWDEF is that it uses regions rather than rectangles wherever possible.}
  22. {This makes it very easy to modify it for making windows with non-rectangular shapes. Few other}
  23. {WDEF samples do that - surprisingly few! Also, I have seen only a single WDEF that allowed}
  24. {resizing with color windows, and that was rectangular.}
  25. {}
  26. {BTW, I found the best way to develop a WDEF with Think Pascal: use a working application (small -}
  27. {Skel is perfect) as its resource file! The application should be configured to use our WDEF for one}
  28. {window. That way, "build code resource" makes a copy of that application with our WDEF in it.}
  29. {Build, switch to Finder and run. Simple! Who needs a special "WDEF tester"? (OK, perhaps for}
  30. {changing the variant code.)}
  31. {}
  32. {Close box is assumed to be rectangular - could perhaps be generalized. Lots and lots of out of}
  33. {memory checks! (All those regions that can take our last byte!) Better rules for deciding color/BW.}
  34. {Standard colors from the appropriate resource instead of the standard blue tint. Better routine}
  35. {and variable names.}
  36. {}
  37. {ASSUMPTIONS that are not necessarily right:}
  38. {- Close/zoom boxes always rectangular and only one of each.}
  39. {- All the window is contents, drag area, frame or shadow - no "dead" parts.}
  40.  
  41. {Version 1.1:}
  42. {Adds support for CodeWarrior.}
  43. {Version 1.2:}
  44. {Updated for CW9.}
  45. {Version 1.3:}
  46. {Fixes a serious bug that could lead to problems when hiding the application.}
  47. {Adds support for user defined globals.}
  48.  
  49. {On the wish list, perhaps for a future release:}
  50. {- Separate handling of parts in different screens}
  51. {- Fat binary}
  52.  
  53.  
  54. unit IngisWDEF;
  55.  
  56. interface
  57.     uses
  58. {$IFC UNDEFINED THINK_PASCAL}
  59.         Types, QuickDraw, ToolUtils, Windows, Events, Memory, OSUtils, 
  60. {$ENDC}
  61.         CustomStubs, IngisWDEFUtils;
  62.  
  63. {$MAIN}
  64.     function main (varCode: integer; macWindow: WindowPeek; theMessage: integer; param: longint): longint;
  65.  
  66. implementation
  67.  
  68.     type
  69.         RectPtr = ^Rect; {For passing the parameter to DrawGrow}
  70.  
  71. {******************************************************}
  72. { GetDragBar                                                                                    }
  73. {                                                                                                }
  74. {        Pass back a region which encloses the drag bar of the window                    }
  75. { Note: dragRgn must already be initialized!                                                 }
  76. { You can probably leave this routine without change!                                        }
  77. { We assume that the contRgn minus the strucRgn, frame and shadow is the dragRgn!}
  78. { *****************************************************}
  79.  
  80.     procedure GetDragBar (varCode: integer; macWindow: WindowPeek; var dragRgn: RgnHandle);
  81.         var
  82.             radius: integer;
  83.             dragBar: Rect;
  84.     begin
  85.         CopyRgn(macWindow^.strucRgn, dragRgn);
  86.         OffsetRgn(dragRgn, -kShadowLength, -kShadowLength);
  87.         SectRgn(dragRgn, macWindow^.strucRgn, dragRgn);
  88.         DiffRgn(dragRgn, macWindow^.contRgn, dragRgn);
  89.         InsetRgn(dragRgn, kFrameWidth, kFrameWidth);
  90.     end;
  91.  
  92.  
  93. {*****************************************************************************}
  94. { DrawFrame}
  95. {}
  96. {        Draw the entire window frame. Calls several custom routines!}
  97. { *****************************************************************************}
  98.  
  99.     procedure DrawFrame (varCode: integer; macWindow: WindowPeek);
  100.         var
  101.             wFrame: Rect;                { Window frame around content rgn    }
  102.  
  103.             wFrameRgn: RgnHandle;
  104.             tmpPt: Point;
  105.             dragBar: RgnHandle;            { Drag bar of window                }
  106.             savePen: PenState;            { Current pen characteristics        }
  107.             saveForeColor, saveBackColor: RGBColor;
  108.             colorFlag: Boolean;
  109.             closeBox, zoomBox: Rect;
  110.     begin
  111.         SaveColors(saveForeColor, saveBackColor);
  112.         GetPenState(savePen);                { Save the current pen state        }
  113.  
  114.         { Structure region of a window has four parts:    }
  115.         {        (1) Frame around the content region        }
  116.         {        (2) Drop shadow                            }
  117.         {        (3) Drag bar                            }
  118.         {        (4) Close box inside the drag bar        }
  119.  
  120.                 { (1) Frame around content region    }
  121.         wFrameRgn := NewRgn;
  122.         CopyRgn(macWindow^.contRgn, wFrameRgn);
  123.         InsetRgn(wFrameRgn, -kFrameWidth, -kFrameWidth);
  124.         PenSize(kFrameWidth, kFrameWidth);
  125.         FrameRgn(wFrameRgn);
  126. {DisposeRgn(wFrameRgn); Not yet- we'll reuse it}
  127.  
  128.                 { (2) Drop shadow below and to the    right of content region        }
  129.         PenSize(kShadowLength, kShadowLength);
  130.  
  131.         CopyRgn(macWindow^.strucRgn, wFrameRgn);
  132.         OffsetRgn(wFrameRgn, -kShadowLength, -kShadowLength);
  133.         DiffRgn(macWindow^.strucRgn, wFrameRgn, wFrameRgn);
  134.         ForeColor(blackColor);
  135.         PaintRgn(wFrameRgn);
  136.         DisposeRgn(wFrameRgn);
  137.  
  138.         dragBar := NewRgn;
  139.         GetDragBar(varCode, macWindow, dragBar);
  140.  
  141.         colorFlag := BitAnd(macWindow^.port.portBits.rowBytes, $8000) <> 0;
  142.         if colorFlag then
  143.             colorFlag := CGrafPtr(macWindow)^.portPixMap^^.pixelSize >= kMinDepthForColor;
  144.         DrawDragBar(varCode, macWindow, dragBar, colorFlag);
  145.  
  146.         DefaultColors;
  147.  
  148.         if macWindow^.hilited then
  149.             if macWindow^.goAwayFlag then
  150.                 begin        { Make sure window has a close box    }
  151.                     GetCloseBox(varCode, dragBar, closeBox);
  152.                     DrawCloseBox(varCode, macWindow, closeBox, colorFlag);
  153.                 end;
  154.         if macWindow^.hilited then
  155.             if macWindow^.spareFlag then
  156.                 begin        { Make sure window has a zoom box    }
  157.                     GetZoomBox(varCode, dragBar, zoomBox);
  158.                     DrawZoomBox(varCode, macWindow, zoomBox, colorFlag);
  159.                 end;
  160.  
  161.         InsetRgn(dragBar, -kFrameWidth, -kFrameWidth);
  162.         PenSize(kFrameWidth, kFrameWidth);
  163.         DefaultColors;
  164.         FrameRgn(dragBar);
  165.         DisposeRgn(dragBar);
  166.  
  167.         SetPenState(savePen);                { Restore original pen state        }
  168.         RestoreColors(saveForeColor, saveBackColor);
  169.     end;
  170.  
  171.  
  172. {*****************************************************************************}
  173. { DoToggleCloseBox}
  174. {}
  175. {        Toggle hiliting of the close box.}
  176. { *****************************************************************************}
  177.  
  178.     procedure DoToggleCloseBox (varCode: integer; macWindow: WindowPeek);
  179.         var
  180.             dragBar: RgnHandle;                { Rectangle enclosing drag bar        }
  181.             closeBox: Rect;                { Rectangle enclosing close box    }
  182.             colorFlag: Boolean;
  183.             saveForeColor, saveBackColor: RGBColor;
  184.             pt: Point;
  185.     begin
  186.         dragBar := NewRgn;
  187.         GetDragBar(varCode, macWindow, dragBar);
  188.         SetRect(closeBox, 0, 0, 0, 0); {If GetCloseBox does nothing, we want an empty rect.}
  189.         if macWindow^.goAwayFlag then
  190.             begin
  191.                 GetCloseBox(varCode, dragBar, closeBox);
  192.  
  193.                 colorFlag := BitAnd(macWindow^.port.portBits.rowBytes, $8000) <> 0;
  194.                 if colorFlag then
  195.                     colorFlag := CGrafPtr(macWindow)^.portPixMap^^.pixelSize >= kMinDepthForColor;
  196.  
  197.                 GetMouse(pt); {Get a point for PtInRect}
  198.                 if colorFlag then
  199.                     SaveColors(saveForeColor, saveBackColor);
  200.                 if PtInRect(pt, closeBox) and Button then
  201.                     DrawHitCloseBox(varCode, macWindow, closeBox, colorFlag)
  202.                 else
  203.                     DrawCloseBox(varCode, macWindow, closeBox, colorFlag);
  204.                 if colorFlag then
  205.                     RestoreColors(saveForeColor, saveBackColor);
  206.             end;
  207.         DisposeRgn(dragBar);
  208.     end; {DoToggleCloseBox}
  209.  
  210. { Same as above, but for the zoom box! }
  211.     procedure DoToggleZoomBox (varCode: integer; macWindow: WindowPeek);
  212.         var
  213.             dragBar: RgnHandle;                { Rectangle enclosing drag bar        }
  214.             zoomBox: Rect;                { Rectangle enclosing close box    }
  215.             colorFlag: Boolean;
  216.             saveForeColor, saveBackColor: RGBColor;
  217.             pt: Point;
  218.     begin
  219.         dragBar := NewRgn;
  220.         GetDragBar(varCode, macWindow, dragBar);
  221.         SetRect(zoomBox, 0, 0, 0, 0); {If GetZoomBox does nothing, we want an empty rect.}
  222.         if macWindow^.spareFlag then
  223.             begin
  224.                 GetZoomBox(varCode, dragBar, zoomBox);
  225.  
  226.                 colorFlag := BitAnd(macWindow^.port.portBits.rowBytes, $8000) <> 0;
  227.                 if colorFlag then
  228.                     colorFlag := CGrafPtr(macWindow)^.portPixMap^^.pixelSize >= kMinDepthForColor;
  229.  
  230.                 GetMouse(pt); {Get a point for PtInRect}
  231.                 if colorFlag then
  232.                     SaveColors(saveForeColor, saveBackColor);
  233.                 if PtInRect(pt, zoomBox) and Button then
  234.                     DrawHitZoomBox(varCode, macWindow, zoomBox, colorFlag)
  235.                 else
  236.                     DrawZoomBox(varCode, macWindow, zoomBox, colorFlag);
  237.                 if colorFlag then
  238.                     RestoreColors(saveForeColor, saveBackColor);
  239.             end;
  240.         DisposeRgn(dragBar);
  241.     end; {DoToggleZoomBox}
  242.  
  243.  
  244. {A little padding around LocalToGlobal.}
  245.     procedure MyLocalToGlobal (macWindow: univ WindowPtr; var p: Point);
  246.         var
  247.             savePort: GrafPtr;
  248.     begin
  249.         GetPort(savePort);
  250.         SetPort(macWindow);
  251.         LocalToGlobal(p);
  252.         SetPort(savePort);
  253.     end;
  254.  
  255.  
  256. {*****************************************************************************}
  257. { FindPart}
  258. {}
  259. {        Find which part of the window was hit by a mouse click at the}
  260. {        specified location.}
  261. { *****************************************************************************}
  262.  
  263.     function FindPart (varCode: integer; macWindow: WindowPeek; location: longint): integer;
  264.         var
  265.             theClick: Point;                { Global coords of mouse click        }
  266.             dragBar, growRgn: RgnHandle;
  267.             closeBox, zoomBox, portR: Rect;
  268.     begin
  269.         theClick.h := LoWord(location);        { Extract horizontal component        }
  270.         theClick.v := HiWord(location);        { Extract vertical component        }
  271.  
  272. { Are we inside the window structure at all?}
  273.         if not PtInRgn(theClick, macWindow^.strucRgn) then
  274.             begin
  275.                 FindPart := wNoHit;
  276.                 Exit(FindPart);
  277.             end;
  278.  
  279. {Must check grow before contRgn, since grow is (often) a part of the contRgn.}
  280.         growRgn := NewRgn;
  281.         GetGrowRgn(varCode, macWindow, growRgn);
  282.         if PtInRgn(theClick, growRgn) then
  283.             begin
  284.                 FindPart := wInGrow;
  285.                 DisposeRgn(growRgn);
  286.                 exit(FindPart);
  287.             end;
  288.         DisposeRgn(growRgn);
  289.  
  290.         if PtInRgn(theClick, macWindow^.contRgn) then
  291.             begin
  292.                 FindPart := wInContent;                { Content region    }
  293.                 Exit(FindPart);
  294.             end;
  295.  
  296.         dragBar := NewRgn;
  297.                                             { Drag bar?    }
  298.         GetDragBar(varCode, macWindow, dragBar);
  299.         if PtInRgn(theClick, dragBar) then
  300.             begin                            { Drag bar or close box! }
  301.                 SetRect(closeBox, 0, 0, 0, 0); {If GetCloseBox does nothing, we want an empty rect.}
  302.                 if macWindow^.goAwayFlag then
  303.                     GetCloseBox(varCode, dragBar, closeBox);
  304.                 SetRect(zoomBox, 0, 0, 0, 0); {If GetZoomBox does nothing, we want an empty rect.}
  305.                 if macWindow^.spareFlag then
  306.                     GetZoomBox(varCode, dragBar, zoomBox);
  307.                 if macWindow^.goAwayFlag and PtInRect(theClick, closeBox) then
  308.                     FindPart := wInGoAway        { Close box! }
  309.                 else if macWindow^.spareFlag and PtInRect(theClick, zoomBox) then
  310.                     begin
  311. {Compare the size of portRect with stdState!}
  312.                         portR := macWindow^.port.portRect;
  313.                         with WStateDataHandle(macWindow^.dataHandle)^^ do
  314.                             if ((portR.right - portR.left) = (stdState.right - stdState.left)) and ((portR.bottom - portR.top) = (stdState.bottom - stdState.top)) then
  315.                                 begin
  316.                                     FindPart := wInZoomIn;
  317.                                 end
  318.                             else
  319.                                 begin {Not match - save the portRect as the userState}
  320.                                     FindPart := wInZoomOut;
  321.                                     MyLocalToGlobal(macWindow, portR.topLeft);
  322.                                     MyLocalToGlobal(macWindow, portR.botRight);
  323.                                     WStateDataHandle(macWindow^.dataHandle)^^.userState := portR;
  324.                                 end;
  325.                     end
  326.                 else
  327.                     FindPart := wInDrag;            { Drag bar and NOT close box! }
  328.             end
  329.         else
  330.             FindPart := wNoHit;            { Click somewhere else. Don't bother. }
  331.         DisposeRgn(dragBar);
  332.     end;
  333.  
  334. {*****************************************************************************}
  335. { BuildRegions}
  336. {}
  337. {        Build the structure and content region of a window.}
  338. { *****************************************************************************}
  339.  
  340.     procedure BuildRegions (varCode: integer; macWindow: WindowPeek);
  341.         var
  342.             theRect: Rect;            { Window regions are rectangular    }
  343.             theRgn: RgnHandle;        { Region defining drop shadow - and everything else we need a temprary region for        }
  344.     begin
  345. {The content region should be calculated from the port rectangle - but, of course, does not}
  346. {have to be identical to it.}
  347.  
  348. {Init the region.}
  349.         theRgn := NewRgn;                { Define region for the shadow        }
  350.  
  351.         theRect := macWindow^.port.portRect;
  352.  
  353.         MyLocalToGlobal(macWindow, theRect.topLeft);
  354.         MyLocalToGlobal(macWindow, theRect.botRight);
  355.  
  356. {CUSTOM: Given the varCode and rectangle, create contRgn and dragRgn (returned in strucRgn)!}
  357.         BuildCustomRegions(varCode, theRect, macWindow^.contRgn, macWindow^.strucRgn);
  358.  
  359. {Build struc, add frame and shadow:}
  360.  
  361. {struc := cont + drag}
  362.         UnionRgn(macWindow^.contRgn, macWindow^.strucRgn, macWindow^.strucRgn);
  363. {Expand struc to include frame}
  364.         InsetRgn(macWindow^.strucRgn, -kFrameWidth, -kFrameWidth);
  365.  
  366. {Make a copy}
  367.         CopyRgn(macWindow^.strucRgn, theRgn);
  368. {Offset it for the shadow}
  369.         OffsetRgn(theRgn, kShadowLength, kShadowLength);
  370. {struc := struc + shadow}
  371.         UnionRgn(macWindow^.strucRgn, theRgn, macWindow^.strucRgn);
  372.  
  373.         DisposeRgn(theRgn);        { All thru with region    }
  374.     end; {BuildRegions}
  375.  
  376.  
  377. {*****************************************************************************}
  378. { DrawGrowFrame - Drawing the frame during window resizing. }
  379. { *****************************************************************************}
  380.  
  381.     procedure DrawGrowFrame (varCode: integer; macWindow: WindowPeek; theRect: Rect);
  382.         var
  383.             tmpContRgn, tmpDragRgn: RgnHandle;
  384.             saveForeColor, saveBackColor: RGBColor;
  385.     begin
  386.         SaveColors(saveForeColor, saveBackColor);
  387.         with theRect do
  388.             begin
  389.                 if right - left < kMinWidth then
  390.                     right := left + kMinWidth;
  391.                 if bottom - top < kMinHeight then
  392.                     bottom := top + kMinHeight;
  393.             end;
  394.  
  395.         tmpContRgn := NewRgn;
  396.         tmpDragRgn := NewRgn;
  397.         BuildCustomRegions(varCode, theRect, tmpContRgn, tmpDragRgn);
  398.         InsetRgn(tmpContRgn, -kFrameWidth, -kFrameWidth);
  399.         InsetRgn(tmpDragRgn, -kFrameWidth, -kFrameWidth);
  400.         FrameRgn(tmpContRgn);
  401.         FrameRgn(tmpDragRgn);
  402.         DisposeRgn(tmpContRgn);
  403.         DisposeRgn(tmpDragRgn);
  404. {The above is well enough, but we also provide a stub for some extra:}
  405.         DrawScrollFrame(varCode, macWindow, theRect);
  406.         RestoreColors(saveForeColor, saveBackColor);
  407.     end;
  408.  
  409. {*****************************************************************************}
  410. { PrepareGrowIcon - Sets up for the custom routine that draws the grow icon. }
  411. {*****************************************************************************}
  412.  
  413.     procedure PrepareGrowIcon (varCode: integer; macWindow: WindowPeek; theRect: Rect);
  414.         var
  415.             tmpRect, smallRect, largeRect: Rect;
  416.         var
  417.             tempClip, saveClip, growRgn: RgnHandle;
  418.             savePort: GrafPtr;
  419.             saveForeColor, saveBackColor: RGBColor;
  420.             colorFlag: Boolean;
  421.     begin
  422.         SaveColors(saveForeColor, saveBackColor);
  423.         theRect := macWindow^.port.portRect;
  424.         MyLocalToGlobal(macWindow, theRect.topLeft);
  425.         MyLocalToGlobal(macWindow, theRect.botRight);
  426.  
  427.         tempClip := NewRgn;
  428.         saveClip := NewRgn;
  429.         growRgn := NewRgn;
  430.  
  431.         GetGrowRgn(varCode, macWindow, growRgn);
  432.  
  433.         SectRgn(macWindow^.port.visRgn, macWindow^.port.clipRgn, tempClip);
  434.         GetClip(saveClip);
  435.         OffsetRgn(tempClip, -macWindow^.port.portRect.left + theRect.left, -macWindow^.port.portRect.top + theRect.top);
  436.         SetClip(tempClip);
  437.  
  438.         DrawScrollFrame(varCode, macWindow, theRect); {Standard eller fritt val?}
  439.         DefaultColors;
  440.  
  441.         colorFlag := BitAnd(macWindow^.port.portBits.rowBytes, $8000) <> 0;
  442.         if colorFlag then
  443.             colorFlag := CGrafPtr(macWindow)^.portPixMap^^.pixelSize >= kMinDepthForColor;
  444.  
  445.         DrawTheGrowIcon(varCode, WindowPeek(macWindow), theRect, growRgn, colorFlag);
  446.  
  447.         RestoreColors(saveForeColor, saveBackColor);
  448.         SetClip(saveClip);
  449.         DisposeRgn(saveClip);
  450.         DisposeRgn(tempClip);
  451.         DisposeRgn(growRgn);
  452.     end;
  453.  
  454.  
  455. {*****************************************************************************}
  456. { SyncPorts - the ugly patch for making it work with Color QD. ONLY called when CQD i available! }
  457. { *****************************************************************************}
  458.  
  459.     procedure SyncPorts;
  460.         var
  461.             bwPort: GrafPtr;
  462.             colorPort: CGrafPtr;
  463.     begin
  464.         GetWMgrPort(bwPort);
  465.         GetCWMgrPort(colorPort);
  466.         SetPort(GrafPtr(colorPort));
  467. {Copy some fields:}
  468.         BlockMove(@bwPort^.pnLoc, @colorPort^.pnLoc, 10);
  469.         BlockMove(@bwPort^.pnVis, @colorPort^.pnVis, 14);
  470.         PenPat(bwPort^.pnPat);
  471.         BackPat(bwPort^.bkPat);
  472.     end;
  473.  
  474.  
  475. {*****************************************************************************}
  476. { Main Function}
  477. { *****************************************************************************}
  478.  
  479. {$MAIN}
  480.     function main (varCode: integer; macWindow: WindowPeek; theMessage: integer; param: longint): longint;
  481.         var
  482.             needSyncPorts: Boolean;
  483.             savePort: GrafPtr;
  484.             theRect: Rect;
  485.     begin
  486.         main := 0;
  487.  
  488.         GetPort(savePort);
  489.  
  490. {Must sync ports on all QuickDraw-dependent routines!}
  491.         if HasCQDraw then {and (theMessage in [wDraw, wHit, wGrow, wDrawGIcon, wCalcRgns])}
  492.             SyncPorts;
  493.  
  494.         case theMessage of                { Take appropriate action            }
  495.  
  496.             wNew: 
  497.                 begin
  498.                     if macWindow^.dataHandle = nil then
  499.                         macWindow^.dataHandle := NewHandleClear(Sizeof(MyDataRecord)); {Allocate space for WStateData AND custom globals!}
  500.                     with WStateDataHandle(macWindow^.dataHandle)^^ do
  501.                         begin
  502.                             stdState := macWindow^.port.portRect;
  503.                             MyLocalToGlobal(macWindow, stdState.topLeft);
  504.                             MyLocalToGlobal(macWindow, stdState.botRight);
  505.                             userState := stdState;
  506.                         end;
  507.                     InitMyWindow(varCode, WindowPeek(macWindow));
  508.                 end;
  509.             wDispose: 
  510.                 begin
  511.                     DisposeMyWindow(varCode, macWindow);
  512.                     if macWindow^.dataHandle <> nil then
  513.                         DisposeHandle(macWindow^.dataHandle);
  514.                     macWindow^.dataHandle := nil;
  515.                 end;
  516.  
  517.             wDraw:                        { Draw the window frame            }
  518.                 if macWindow^.visible then     { Only draw if window is visible    }
  519.                     case BAnd(param, $0000FFFF) of    { Find out which part to draw        }
  520.  
  521.                         wNoHit:        { Draw the entire frame            }
  522.                             begin
  523.                                 DrawFrame(varCode, macWindow);
  524.                             end;
  525.  
  526.                         wInGoAway:        { Toggle hiliting of the close box    }
  527.                             DoToggleCloseBox(varCode, macWindow);
  528.  
  529.                         wInZoomIn, wInZoomOut:        { Toggle hiliting of the close box    }
  530.                             DoToggleZoomBox(varCode, macWindow);
  531.                     end;
  532.  
  533.             wHit:                        { Find part of window clicked in    }
  534.                 main := FindPart(varCode, macWindow, param);
  535.  
  536.             wCalcRgns:                    { Build structure & content rgns    }
  537.                 BuildRegions(varCode, macWindow);
  538.  
  539.             wGrow: 
  540.                 DrawGrowFrame(varCode, macWindow, RectPtr(param)^);
  541.  
  542.             wDrawGIcon: 
  543.                 PrepareGrowIcon(varCode, macWindow, theRect); {Set up and calls DrawTheGrowIcon}
  544.         end; {case}
  545.  
  546.         SetPort(savePort);
  547.  
  548.     end; {main}
  549.  
  550. end.